package com.gist.cithub.comment.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gist.common.utils.PageUtils;
import com.gist.common.utils.Query;

import com.gist.cithub.comment.dao.ReplyDao;
import com.gist.cithub.comment.entity.ReplyEntity;
import com.gist.cithub.comment.service.ReplyService;


@Service("replyService")
public class ReplyServiceImpl extends ServiceImpl<ReplyDao, ReplyEntity> implements ReplyService {
    @Autowired
    ReplyDao replyDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<ReplyEntity> page = this.page(
                new Query<ReplyEntity>().getPage(params),
                new QueryWrapper<ReplyEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<ReplyEntity> getCommentsByRootId(Integer rootid) {
        QueryWrapper<ReplyEntity> queryWrapper=new QueryWrapper<>();
        queryWrapper.and(
                wrapper ->
                        wrapper.eq("rootid",rootid)
        );
        List<ReplyEntity> replyEntityList=replyDao.selectList(queryWrapper);
        return replyEntityList;
    }

}